#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 1e6+50;

struct node
{
	int u, v, w;
	bool operator < (const node &other) const
	{
		return u != other.u ? u < other.u : v > other.v;
	}
} a[N];

int st[N], scnt;
int n;
LL tmp[N];
int tcnt;
LL t2[N];
typedef multiset<LL, greater<LL>> T;

T S[N];
vector<int> G[N];

void dfs(int u)
{
	// dbg(u);
	if (!G[u].size())
	{
		S[u].insert(a[u].w);
		return;
	}
	int maxson = -1, msize = 0;
	for (int v : G[u])
	{
		dfs(v);
		if ((int)S[v].size() > msize)
		{
			msize = S[v].size();
			maxson = v;
		}
	}
	S[u].swap(S[maxson]);
	tcnt = 0;

	for (int v : G[u])
	{
		if (v == maxson) continue;
		tcnt = max(tcnt, (int)S[v].size());
		int tt = 0;
		for (LL x : S[v])
			tmp[tt++] += x;
	}
	for (int i=0; i<tcnt; ++i)
	{
		tmp[i] += *S[u].begin();
		S[u].erase(S[u].begin());
	}
	for (int i=0; i<tcnt; ++i)
		S[u].insert(tmp[i]);
	memset(tmp, 0, sizeof(LL) * tcnt);
	S[u].insert(a[u].w);
}

inline bool in(const node &a, const node &b)
{
	return a.u <= b.u && b.v <= a.v;
}

LL diff[N];
int dcnt;

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	// n = 0);
	for (int i=0; i<n; ++i)
	{
		scanf("%d%d%d", &a[i].u, &a[i].v, &a[i].w);
	}
	
	sort(a, a+n);
	a[n] = {0, 1000005, 0};
	st[scnt++] = n;
	for (int i=0; i<n; ++i)
	{
		while (scnt && !in(a[st[scnt-1]], a[i]))
			--scnt;
		int fa = st[scnt-1], son = i;
		// dbg(fa, son);
		G[fa].push_back(son);
		st[scnt++] = i;
	}
	dfs(n);
	// dbg(S[n].size());
	for (LL x : S[n])
		diff[dcnt++] = x;
	// return 0;
	--dcnt;
	for (int i=1; i<dcnt; ++i)
		diff[i] += diff[i-1];
	// return 0;
	// printf("%d\n", dcnt); return 0;
	for (int i=dcnt; i<n; ++i)
		diff[i] = diff[dcnt-1];
	// return 0;
	for (int i=0; i<n; ++i)
		printf("%lld%c", diff[i], i==n-1? '\n':' ');
	
	return 0;
}